package com.lvy.hczn.transmit.controller;

import com.lvy.hczn.front.common.core.controller.BaseController;
import com.lvy.hczn.front.common.core.domain.AjaxResult;
import com.lvy.hczn.front.common.exception.UtilException;
import com.lvy.hczn.mq.rocket.ParamInfo;
import com.lvy.hczn.transmit.service.DepotSkuDetailService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RequestMapping("/api/dt/depot/")
@RestController
@Slf4j
public class DepotSkuDetailController extends BaseController {

    @Autowired
    private DepotSkuDetailService depotSkuDetailService;

    @ApiOperation(value = "查询仓库临期可报损商品", notes = "查询仓库临期可报损商品")
    @PostMapping("test")
    public AjaxResult depotSkuDetailTest(HttpServletRequest request, @RequestBody ParamInfo info) {
        try {
            depotSkuDetailService.selectByFrmLossByWarehouseCode(info);
            return AjaxResult.success();
        } catch (Exception e) {
            if (e instanceof UtilException) {
                return AjaxResult.error(e.getMessage());
            } else {
                log.error("depotSkuDetailTest异常：{}", e);
                return AjaxResult.error("系统异常");
            }
        }
    }
}
